package com.zkingsoft.zkingbase.adapter;

import android.content.Context;
import android.support.annotation.LayoutRes;
import android.widget.ImageView;
import android.widget.TextView;

import com.zkingsoft.zkingbase.R;
import com.zkingsoft.zkingbase.bean.Goods;
import com.zkingsoft.zkingbase.holder.BaseViewHolder;

import java.util.List;

import butterknife.BindView;

/**
 * Created by ytf on 2017/3/4 004.
 * Description:
 */

public class GoodsListAdapter extends DefaultAdapter<Goods>
{
    public GoodsListAdapter(Context context, List<Goods> datas)
    {
        super(context, datas);
    }

    @Override
    protected BaseViewHolder<Goods> getHolderInstance(Context context)
    {
        return new ViewHolder(context);
    }

    class ViewHolder extends BaseViewHolder<Goods>
    {

        @BindView(R.id.iv_preview)
        ImageView ivPreview;
        @BindView(R.id.tv_desc)
        TextView tvDesc;
        @BindView(R.id.tv_price)
        TextView tvPrice;

        public ViewHolder(Context context)
        {
            super(context);
        }

        @Override
        @LayoutRes
        protected int getViewLayout()
        {
            return R.layout.item_goods_list;
        }

        @Override
        protected void refreshView(int position)
        {
            showImg(mContext, data.getImgUrl(), ivPreview);
            tvDesc.setText(data.getDescription());
            tvPrice.setText(String.valueOf(data.getPrice()));
        }
    }

}
